package com.chang.soul.service.imp;

import com.chang.soul.bean.ArticleBean;
import com.chang.soul.bean.ArticleQueryForm;
import com.chang.soul.dao.ArticleMapper;
import com.chang.soul.service.ArticleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ArticleServiceImp implements ArticleService {

    @Autowired
    ArticleMapper articleMapper;

    @Override
    public boolean insertArticle(ArticleBean articleBean) {
        try{
            articleMapper.insertArticle(articleBean);
        }catch (Exception e){
            System.out.println(e);
            return false;
        }
        return true;
    }

    @Override
    public boolean deleteArticleById(Integer id) {
        try{
            articleMapper.deleteArticleById(id);
        }catch (Exception e){
            System.out.println(e);
            return false;
        }
        return true;
    }

    @Override
    public boolean updateArticle(ArticleBean articleBean) {
        try{
            articleMapper.updateArticle(articleBean);
        }catch (Exception e){
            System.out.println(e);
            return false;
        }
        return true;
    }

    @Override
    public List<ArticleBean> getAllArticleList(ArticleQueryForm articleQueryForm) {
        return articleMapper.getAllArticleList(articleQueryForm);
    }

    @Override
    public int getCountByArticleList(ArticleQueryForm articleQueryForm) {
        return articleMapper.getCountByArticleList(articleQueryForm);
    }

    @Override
    public ArticleBean getArticleById(int id) {
        return articleMapper.getArticleById(id);
    }

    @Override
    public Integer getArticleCount() {
        return articleMapper.getArticleCount();
    }


}
